package bz.ziro.kanbe.controller.mng.comment;

import java.util.logging.Logger;

import org.slim3.controller.Controller;
import org.slim3.controller.Navigation;

import bz.ziro.kanbe.dao.CommentDao;
import bz.ziro.kanbe.model.CommentConfig;
import bz.ziro.kanbe.util.KeyFactory;

import com.google.appengine.api.datastore.Key;

public class FindConfigController extends Controller {

    @SuppressWarnings("unused")
    private static final Logger logger = Logger.getLogger(FindConfigController.class.getName());

    @Override
    public Navigation run() {
        String siteKeyBuf = sessionScope("siteKey");
        String templateKeyBuf = requestScope("templateKey");

       	//テンプレートのキーを取得
       	Key templateKey = KeyFactory.createTemplateKey(Long.valueOf(siteKeyBuf),Long.valueOf(templateKeyBuf));
        //コメント設定を取得
        CommentConfig config = CommentDao.findConfig(templateKey);
        if ( config == null ) {
        	config = new CommentConfig();
        }
        requestScope("config",config);

        return forward("find.jsp");
    }
}
